package org.datacoder.geocoding.datastructures.geoshapes

import com.vividsolutions.jts.geom.*
import com.vividsolutions.jts.geom.impl.*
import org.datacoder.geocoding.*

/**
 * The left edge of the bounding rectangle of
 * a jurisdiction.
 */
class GeoVtInterval extends GeoInterval {

    public double lon
    public double lat1
    public double lat2

    public double retrieveSingleValue(){
        return lon
    }
    public double retrieveMinDoubleValue(){
        return lat1
    }
    public double retrieveMaxDoubleValue(){
        return lat2
    }

    public boolean intersectsGeoHzInterval(GeoHzInterval ghi){
        if((ghi.lon1 <= lon) && (lon <= ghi.lon2) &&
            (lat1 <= ghi.lat) && (ghi.lat <= lat2)){
            return true
        }else{
            return false
        }
    }

    public Geometry toGeometry(){
        Coordinate[] endPoints = new Coordinate[2]
        endPoints[0] = new Coordinate(lon, lat1)
        endPoints[1] = new Coordinate(lon, lat2)
        LineString lineString = new LineString(
            new CoordinateArraySequence(endPoints),
            GeocodingUtils.geometryFactory
        )
        return lineString
    }

}

